
import {ENABLED} from "/@/utils/dict/Dict";
import {ref} from "vue";
import {DictDataModel} from "/@/api/system/model/DictModel";
import {Column} from "/@/components/Base/BaseEditTable/ts";
export const fieldTypeOptions = ref<DictDataModel[]>([])
export const screenOptions = ref<DictDataModel[]>()
export const componentTypeOptions = ref<DictDataModel[]>([]);
export const tableSonTypeOptions =  ref<DictDataModel[]>([]);
export const columns: Column[] = [
    {
        label: '序号',
        type: 'index',
        align: 'center',
        fixed:"left",
        headerAlign: 'center',
        width: "70"
    },
    {
        label: '字段名称',
        prop: 'fieldName',
        component: "Input",
        align: 'center',
        width: '200',
        fixed:"left",
        headerAlign: 'center',
        componentAttr:{
            placeholder: '字段名称'
        }
    },
    {
        label: '描述名称',
        prop: 'fieldDesc',
        width: '200',
        component: "Input",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '描述名称'
        }
    },
    {
        label: '字段类型',
        prop: 'fieldType',
        width: '120',
        component: "Select",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '字段类型',
            toNumber: true,
            options: fieldTypeOptions
        }
    },
    {
        label: '组件类型',
        prop: 'componentType',
        width: '120',
        component: "Select",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '组件类型',
            options: componentTypeOptions
        }
    },
    {
        label: '字段长度',
        prop: 'fieldLength',
        width: '120',
        component: "InputNumber",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '字段长度',
        }
    },
    {
        label: '是否唯一',
        prop: 'onlyKey',
        width: '90',
        component: "Switch",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            activeValue: ENABLED.YES,
            inactiveValue: ENABLED.NO
        }
    },
    {
        label: '是否主键',
        width: '90',
        align: 'center',
        headerAlign: 'center',
        prop: 'primaryKey',
        component: "Switch",
        componentAttr:{
            activeValue: ENABLED.YES,
            inactiveValue: ENABLED.NO
        }
    },
    {
        label: '是否为空',
        prop: 'emptyKey',
        component: "Switch",
        width: '90',
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            activeValue: ENABLED.YES,
            inactiveValue: ENABLED.NO
        }
    },
    {
        label: '是否查询',
        prop: 'queryBol',
        width: '90',
        component: "Switch",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            activeValue: ENABLED.YES,
            inactiveValue: ENABLED.NO
        }
    },
    {
        label: '是否列表',
        prop: 'listBol',
        width: '90',
        component: "Switch",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            activeValue: ENABLED.YES,
            inactiveValue: ENABLED.NO
        }
    },
    {
        label: '是否插入',
        prop: 'insertBol',
        width: '90',
        component: "Switch",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            activeValue: ENABLED.YES,
            inactiveValue: ENABLED.NO
        }
    },
    {
        label: '是否修改',
        prop: 'updateBol',
        width: '90',
        component: "Switch",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            activeValue: ENABLED.YES,
            inactiveValue: ENABLED.NO
        }
    },
    {
        label: '筛选条件',
        prop: 'screen',
        width: '120',
        component: "Select",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '筛选条件',
            toNumber: true,
            options: screenOptions
        }
    },
    {
        label: '字典编号',
        width: '120',
        prop: 'dictTypeCode',
        component: "Input",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '字段名称'
        }
    },
    {
        label: '操作',
        fixed:"right",
        align: 'center',
        width: '200',
        headerAlign: 'center',
        prop: 'operate',
        custom: 'operate'
    }
]

export const  tableColumns: Column[] = [
    {
        label: '序号',
        type: 'index',
        align: 'center',
        fixed:"left",
        headerAlign: 'center',
        width: "70"
    },
    {
        label: '表名称',
        prop: 'tableName',
        component: 'Input',
        readonly: true,
        align: 'center',
        width: '200',
        fixed:"left",
        headerAlign: 'center',
    },
    {
        label: '类型',
        prop: 'type',
        width: '120',
        component: "Select",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '类型',
            toNumber: true,
            options: tableSonTypeOptions
        }
    },
    {
        label: '指令名称',
        prop: 'templateName',
        component: "Input",
        align: 'center',
        headerAlign: 'center',
        componentAttr:{
            placeholder: '指令名称'
        }

    },
    {
        label: '操作',
        fixed:"right",
        align: 'center',
        width: '200',
        headerAlign: 'center',
        prop: 'operate',
        custom: 'operate'
    }
]
export const fieldsTableRules = {
    fieldName: [
        {required: true, message: '请输入字段名称', trigger: 'blur'},
        {min: 1, max: 64, message: '字段名称长度为1到64', trigger: 'blur'},
    ],
    fieldDesc: [
        {required: true, message: '请输入描述名称', trigger: 'blur'},
        {min: 1, max: 64, message: '描述名称长度为1到64', trigger: 'blur'},
    ],
    fieldType: [
        {required: true, message: '请选择字段类型', trigger: 'blur',type: 'number'},
    ],
    fieldLength: [
        {required: true, message: '请输入字段长度', trigger: 'blur',type: 'number'},
    ],
    dictTypeCode: [
        { max: 64, message: '字典编号长度为1到64', trigger: 'blur'},
    ]
}

export const fieldsSonTableRules = {
    type: [
        {required: true, message: '请选择类型', trigger: 'blur',type: 'number'},
    ],
    templateName: [
        {required: true, message: '请输入指令名称', trigger: 'blur'},
        {min: 1, max: 64, message: '指令名称长度为1到64', trigger: 'blur'},
    ]
}